<template>
  <el-table :data="get_goodsList" border style="width: 100%">
    <el-table-column prop="id" label="商品编号" width="80"></el-table-column>
    <el-table-column prop="goodsname" label="商品名称" width="180"></el-table-column>
    <el-table-column prop="price" label="商品价格"></el-table-column>
    <el-table-column prop="market_price" label="市场价格"></el-table-column>
    <el-table-column prop="img" label="图片">
      <template v-slot="item">
        <img v-if="item.row.img" :src="$baseUrl + item.row.img" width="80px" height="80px">
      </template>
    </el-table-column>

    <el-table-column prop="isnew" label="是否新品">
      <template v-slot="item">
        <el-button type="primary" plain size="small" v-if="item.row.isnew == 1">是</el-button>
        <el-button type="danger" plain size="small" v-else>否</el-button>
      </template>
    </el-table-column>

    <el-table-column prop="ishot" label="是否热卖">
      <template v-slot="item">
        <el-button type="primary" plain size="small" v-if="item.row.ishot == 1">是</el-button>
        <el-button type="danger" plain size="small" v-else>否</el-button>
      </template>
    </el-table-column>

    <el-table-column prop="status" label="状态">
      <template v-slot="item">
        <el-button type="primary" plain size="small" v-if="item.row.status == 1">启用</el-button>
        <el-button type="danger" plain size="small" v-else>禁用</el-button>
      </template>
    </el-table-column>

    <el-table-column label="操作">
      <template v-slot="item">
        <el-button type="primary" size="small" @click="edit(item.row.id)">编辑</el-button>
        <el-button type="danger" size="small">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters("goods", ["get_goodsList"])
  },
  methods: {
    ...mapActions("goods", ["action_goodsList"]),
    //1.编辑
    edit(id){
      this.$emit("edit",id)
    }
  },
  mounted() {
    this.action_goodsList();
  }
};
</script>

<style>
</style>